package com.pl.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author shent
 */
@Service
public class RedisProducerImpl {
    @Autowired
    private RedisTemplate redisTemplate;

    public String produce(String key, String msg) {
        Map<String, String> map = new HashMap<>();
        map.put("field", msg);
        if (redisTemplate.opsForList().leftPush(key, map) == 0) {
            return null;
        }
        return "ok";
    }
}
